/***********************************************
 This file is part of redia-bapps-main-ios.
 
 Copyright (c) 2015 Redia A/S
 
 Redia-bapps-main-ios is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.
 
 Redia-bapps-main-ios is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with redia-bapps-main-ios.  If not, see <http://www.gnu.org/licenses/>.
 
 *********************************************** */

//
//  BAUserGuideViewController.m
//  redia-bapps-ios
//
//  Created by Henrik Lynbech on 12/02/14.
//  Copyright (c) 2014 redia. All rights reserved.
//

#import "BAUserGuideViewController.h"
#import "BALightFrameButton.h"
#import "BARootViewController.h"
#import "BALibrarySettings.h"


@interface BAUserGuideViewController () {
    BOOL didAlreadyDismiss;
}

@property (weak, nonatomic) IBOutlet BALightFrameButton *closeButton;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *closeButtonTopSpaceConstraint;
@property (weak, nonatomic) IBOutlet UIImageView *functionImage;

@end

@implementation BAUserGuideViewController

- (IBAction)closeButtonClicked:(id)sender {
    if (!didAlreadyDismiss) {
        [[BARootViewController instance] dismissUserGuide:self];
        didAlreadyDismiss=YES;
    }
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    if ([[BAUtils instance] iOSMajorVersion] < 7) {
        self.closeButtonTopSpaceConstraint.constant = 10;
    }
    
    if (![BALibrarySettings instance].isScannerEnabled) {
        if (RD_IS_IPHONE5) {
            self.functionImage.image = [UIImage imageNamed:@"function-guide-no-barcode-iphone5"];
        } else{
            self.functionImage.image = [UIImage imageNamed:@"function-guide-no-barcode"];
        }
        
    } else if (RD_IS_IPHONE5) {
        self.functionImage.image = [UIImage imageNamed:@"function-guide-iphone5"];
    }
    
    
    
    
    didAlreadyDismiss=NO;
    
    UITapGestureRecognizer* gest = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closeButtonClicked:)];
    [self.functionImage addGestureRecognizer:gest];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
